package Practice07;

import java.io.*;
import java.util.Scanner;

public class test4 {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String pathname = sc.nextLine();
        File f = new File(pathname);
        File f2 = null;
        OutputStreamWriter osw = null;
        InputStreamReader isr = null;
        try {
            if (f.exists()){
                f2 = new File(pathname.substring(0,pathname.lastIndexOf("."))+"_copy"+pathname.substring(pathname.lastIndexOf(".")));
                osw = new OutputStreamWriter(new FileOutputStream(f2));
                isr = new InputStreamReader(new FileInputStream(f));
                char[] b = new char[512];
                isr.read(b);
                osw.write(b);

                System.out.println("该文件已存在，复制完成");
            }else {
                System.out.println("该文件不存在");
            }
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                if (osw != null) {
                    osw.close();
                }
                if (isr != null) {
                    isr.close();
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

    }
}
